package com.aabte.weather.wearthercollection.city;

import com.aabte.weather.city.api.CityApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.LinkedList;
import java.util.List;

@Slf4j
@Service
public class CityDataServiceImpl implements CityDataService {

    @Resource
    private CityApi cityApi;

    @Override
    public List<City> listCity() {
        List<com.aabte.weather.city.api.City> cities = cityApi.listCity();
        List<City> cityList = new LinkedList<>();
        for (com.aabte.weather.city.api.City city : cities) {
            City city1 = new City(city.getCityId(), city.getCityName(), city.getCityCode(), city.getProvince());
            cityList.add(city1);
        }
        return cityList;
    }
}
